package com.adingxiong.quickstart.project.service.impl;

import com.adingxiong.quickstart.project.entity.User;
import com.adingxiong.quickstart.project.mapper.UserMapper;
import com.adingxiong.quickstart.project.service.IUserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xiongc
 * @since 2020-05-21
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
    @Override
    public User getUserById(Long id) {
        return baseMapper.selectById(id);
    }

    @Override
    public User login(String login, String password) {
        QueryWrapper<User> query = new QueryWrapper<>();
        Map<String,String> param = new HashMap<>();
        param.put("username",login);
        param.put("password",password);
        User user = baseMapper.selectOne(query.allEq(param));
        return  user;
    }
}
